package metier.model;

import java.util.List;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.ManyToMany;
import org.apache.commons.lang3.builder.EqualsBuilder;
import org.apache.commons.lang3.builder.HashCodeBuilder;
import org.apache.commons.lang3.builder.ToStringBuilder;

@Entity
public class Role {

    @Id
    @Column
    private String code;
    @Column
    private String libelle;
    @ManyToMany(mappedBy = "listeRole")
    private List<Profil> listeProfil;

    public Role() {
    }

    public String getCode() {
        return code;
    }

    public void setCode(String code) {
        this.code = code;
    }

    public String getLibelle() {
        return libelle;
    }

    public void setLibelle(String libelle) {
        this.libelle = libelle;
    }

    public List<Profil> getListeProfil() {
        return listeProfil;
    }

    public void setListeProfil(List<Profil> listeProfil) {
        this.listeProfil = listeProfil;
    }

    @Override
    public int hashCode() {
        return new HashCodeBuilder().append(code).toHashCode();
    }

    @Override
    public boolean equals(Object object) {
        if (object == null) {
            return false;
        }
        if (object == this) {
            return true;
        }
        if (object.getClass() != getClass()) {
            return false;
        }
        Role other = (Role) object;
        return new EqualsBuilder().append(code, other.code).isEquals();
    }

    @Override
    public String toString() {
        return new ToStringBuilder(this).append(code).toString();
    }

}
